package org.smart4j.plugin.security;

import java.util.concurrent.CopyOnWriteArrayList;

import org.smart4j.framework.helper.ConfigHelper;
import org.smart4j.framework.util.ReflectUtil;
import org.springframework.util.ReflectionUtils;

/**
 * description: 从配置文件中获取相关属性
 * @version v1.0
 * @author w
 * @date 2018年11月4日下午8:36:04
 **/
public class SecurityConfig {
	
	/**
	 * description: 获取Realms
	 * @return
	 * @return String
	 * @version v1.0
	 * @author w
	 * @date 2018年11月4日 下午8:45:05
	 */
	public static String getRealms(){
		return ConfigHelper.getString(SecurityConstant.REALMS);
	}
	
	/**
	 * description: 获取 SmartSecurity 安全对象
	 * @return SmartSecurity
	 * @version v1.0
	 * @author w
	 * @date 2018年11月4日 下午8:51:16
	 */
	public static SmartSecurity getSmartSecurity(){
		String className = ConfigHelper.getString(SecurityConstant.SMART_SECURITY);
		return (SmartSecurity)ReflectUtil.newInstanse(className);
	}
	
	public static String getJdbcAuthQuery(){
		return ConfigHelper.getString(SecurityConstant.JDBC_AUTHC_QUERY);
	}
	
	public static String getJdbcRolesQuery(){
		return ConfigHelper.getString(SecurityConstant.JDBC_ROLES_QUERY);
	}
	
	public static String getJdbcPermissionsQuery(){
		return ConfigHelper.getString(SecurityConstant.JDBC_PERMISSIONS_QUERY);
	}
	
	public static boolean isCacheable(){
		return ConfigHelper.getBoolean(SecurityConstant.CACHE);
	}

	
}
